Supporting QuickDraw GX Print Dialog Boxes
Dialog boxes for QuickDraw GX printing features are movable modal. A movable modal dialog box is a modal dialog box that contains a title bar by which users can drag the dialog box. This type of dialog box allows users to view windows that would otherwise be obscured by the dialog box. Movable modal dialog boxes are described in Inside Macintosh: Macintosh Toolbox Essentials.To support QuickDraw GX print dialog boxes, your application needs to identify the Edit menu and its menu items, adjust the menu bar to enable or disable appropriate menu items, and respond to the
gxPrintingEvent
message that QuickDraw GX sends to your application.You make menu adjustments just before you display the dialog box. Examples of setting up the menu bar are shown in the sections "Displaying the Page Setup Dialog Box" beginning on page 2-35 and "Displaying the Print Dialog Box" beginning on page 2-37.
This section shows how to set up the override for the
gxPrintingEvent
message. QuickDraw GX sends this message to your application each time it receives an event, such as a mouse click or a keystroke. Because you want the application to respond to update events so that the window can be redrawn, you must install the application as a handler for thegxPrintingEvent
message.You create a function that has the same prototype (the same format of parameters and return value) as the
GXPrintingEvent
function and install it in the message chain. To override thegxPrintingEvent
message, you specify a pointer to an override function in theGXInstallApplicationOverride
function. Because dialog boxes are associated with individual job objects, you must callGXInstallApplicationOverride
after you create each job object.The override persists until you dispose of the job object or install another override for the
gxPrintingEvent
message. Listing 2-1 on page 2-12 shows the following call in the context of creating a new job object:
GXInstallApplicationOverride(myDocument->documentJob, gxPrintingEvent, MyPrintingEventOverride);TheGXInstallApplicationOverride
function has three parameters:
The parameters to the override function named
- A reference to the job object. In Listing 2-1 on page 2-12, it is the job object that was stored when the document was created.
- The ID of the message to override. In this case, it is
gxPrintingEvent.
- The function that responds to the message. In this case, it is
MyPrintingEventOverride
.
MyPrintingEventOverride
must match those of theGXPrintingEvent
message override function, which has the following declaration:
OSErr GXPrintingEvent (EventRecord *anEventRecord, Boolean filterEvent);TheanEventRecord
parameter is a pointer to the event record, which contains information about what type of event occurred while the print dialog box was being displayed; for example, a mouse click or key-down. The event record also contains additional information associated with the event, such as which key was pressed for a key-down event.The
filterEvent
parameter specifies whether the event can be filtered. QuickDraw GX sends twogxPrintingEvent
messages for each event. The first event can be filtered, for example, by calling theDialogSelect
function to filter non-update events.
Listing 2-4 shows an override function for the
- Note
- The Window Manager generates update events to control the appearance of windows on the screen. The
EventRecord
data type, the Window Manager, theDialogSelect
function, and update events are discussed in Inside Macintosh: Macintosh Toolbox Essentials.![]()
gxPrintingEvent
message.Listing 2-4 Override function for the
gxPrintingEvent
message
OSErr MyPrintingEventOverride(EventRecord *anEvent, Boolean filterEvent) { OSErr err = noErr; /* Handle events in whatever way is appropriate. MyDoEvent is a generic event handler. Don't pass it events that it shouldn't handle while print dialogs are displayed. */ if (!filterEvent) switch (anEvent->what) { case mouseDown: case keyDown: case autoKey: break; default: err = MyDoEvent(anEvent); } return err; }In Listing 2-4, if the event is not a filter event,
- Note
- You do not need to forward the
gxPrintingEvent
message.![]()
MyDoEvent
is called because the event is probably an update event. TheMyDoEvent
function is the general-purpose, application-specific function that handles all events and is typically called after eachWaitNextEvent
. TheMyDoEvent
function is called from this override to dispatch redrawing of the document's window in response to an update event.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help